<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.lgx.right.entity.User"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=basePath %>style/base.css" type="text/css" rel="stylesheet" />
	<link href="<%=basePath %>style/shopping-cart.css" type="text/css" rel="stylesheet" /><!-- 购物车样式 -->
	<jsp:include page="/page/jsp/member/head.jsp" />
	
	<script type="text/javascript">
		function continueShop(){
			parent.window.location = path;
		}
		
		//管理订单跳转
		function address(){
			window.location = path+"/member/myOrderURL.htm";
		}
		
		/* 提交退货申请，暂不支持批量退货   */
		function submitRetrun(orderNo){
			if(orderNo!=null){   //如果这个商品没有订单映射，不允许执行退货申请
				//接受页面参数
				var reason = escape(escape($('#reason').val()));         //获取退货原因
				var explain = escape(escape($('#explain').val()));       //获取退货说明
				var imageUrl = escape(escape($('#imageUrl').val()));   //获取退货凭证图片路径
				
				if(reason==''||reason == 0){
					alertBox("请选择退货原因!");
				}else if(explain==''){
					alertBox("请选填写退货缘由!");
				}else if(imageUrl==''){
					alertBox("请上传凭证图片!");
				}else{
					$.ajax({
						  url:path+"/member/returnProduct.htm?orderNo="+orderNo+"&reason="+reason+"&explain="+explain+"&imageUrl="+imageUrl,
						  success: function(data) {
							  if(data == "0"){
								  window.location = path+"/member/myOrderURL.htm";   //成功跳转到管理订单页面
							   }else if(data == "2"){
								   alertBox("未找到对应的订单！");
							   }else{
								   alertBox("申请失败！");
							   } 
						  }
						});
				}
			}
		}
		
		
		function selectImage(){
	       	var w =(screen.width-300)/2;
			var h = (screen.height-60)/2;
			var ret = window.showModalDialog(path+"/page/jsp/member/image-upload.jsp",window,"dialogWidth:300px;dialogHeight:60px;dialogTop:"+h+"px;dialogLeft:"+w+"px;help:no;status:no;center:yes");
			if(ret != null){
				$('#image').attr('src',path+"/"+ret[0][0]);
				$('#imageUrl').attr('value',ret[0][0]);
			}
		}
	</script>
  </head>
  
  <body>
  <div class="right">
  	<h1><b>退货清单</b><span><img src="<%=basePath%>images/right_h1bg2.jpg" width="3" height="29" /></span></h1>
	<div class="ri_main">
	<ol class="flow-steps">
		<li class="s2 suc">确认订单信息</li>
		<li class="s3 suc">成功提交订单</li>
		<li class="s4 cur">申请退货</li>
	</ol>
	<div class="returns-info">
		<div class="hd"><strong class="hd-t">退货清单</strong><a href="#" target="_blank" class="hd-act">返回重新修改退货清单</a></div>
		<table class="shop-pro-list">
			<thead>
				<tr>
					<th>商品编号</th>
					<th>商品名称</th>
					<th>积分</th>
					<th>库存状态</th>
					<th>商品数量</th>
				</tr>
			</thead>
			<tbody>
			<c:if test="${orderDetail != null}"><!-- 单个退货使用 -->
				<tr>
					<td><a href="${orderDetail.entityUrl}" target="_blank">${orderDetail.entityId}</a></td>
					<td><a href="${orderDetail.entityUrl}" target="_blank">${orderDetail.entityName}</a></td>
					<td>${orderDetail.price}</td>
					<td>现货</td>
					<td>${orderDetail.amount}</td>
				</tr>
			</c:if>
			<%-- <c:if test="${orderDetaiList != null}"><!-- 批量退货使用 -->
				<c:forEach var="odl" items="${orderDetaiList}">
					<tr>
						<td><a href="${odl.entityUrl}" target="_blank">${odl.entityId}</a></td>
						<td><a href="${odl.entityUrl}" target="_blank">${odl.entityName}</a></td>
						<td>${odl.price}</td>
						<td>现货</td>
						<td>${odl.amount}</td>
					</tr>
				</c:forEach>
			</c:if> --%>
				
			</tbody>
		</table>
		<div class="returns-form">
			<form action="#" method="post" name="returns-form">
				<fieldset class="bd">
					<legend>填写退货理由</legend>
					<table>
						<tr>
							<th>退款原因：<span class="mark">*</span></th>
							<td>
								<select name="select" id="reason">
									<option value="0" selected="selected">请选择退款原因</option>
									<c:forEach var="dict" items="${returnReasons}">
						    			<option value="${dict.code }"> ${dict.name } </option>
						    		</c:forEach>
                                </select>
							</td>
						</tr>
						<tr>
							<th>退款说明：<span class="mark">*</span></th>
							<td>
								<textarea value="0-200个字" cols="66" rows="5" id="explain" class="input-area"></textarea>
							</td>
						</tr>
						<tr class="file-area">
							<th>上传凭证：<span class="mark">*</span></th>
							<td bgcolor="#FFFFFF">
								<img id="image" width="200" height="200" name="image" src="<%=basePath %>${product != null?product.imageUrl1:''}"></img>
						    	<input type="hidden" id="imageUrl" name="imageUrl" value="${product != null?product.imageUrl1:''}">
						    	<input type="button" onclick="selectImage()" value="选择" />
							</td>
						</tr>
						<tr>
							<th>&nbsp;</th>
							<td>
							<c:if test="${orderDetail != null}"><!-- 单个退货使用 -->
								<input name="ret-btn" type="button" onclick="submitRetrun(${orderDetail.order.orderNo})" value="提交退货申请" class="ret-btn">
							</c:if>
							
							<%-- <c:if test="${orderDetaiList != null}">
								<input name="ret-btn" type="button" onclick="submitRetrun(${orderDetaiList.get[0].order.orderNo})" value="提交退货申请" class="ret-btn">
							</c:if> --%>
								
							</td>
						</tr>
					</table>
				</fieldset>
			</form>
		</div>
		
	</div>
	</div>
</div>

<!-- S 自定义脚本 -->
<script src="js/jquery-1.3.2.min.js"></script>
<script src="js/jquery.soChange-min.js"></script>
<script src="js/shop-car.js"></script>
<script src="js/tab.js"></script>
  </body>
</html>
